<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <script type="text/javascript" src="./script/rem.js"></script>
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  <meta content="yes" name="apple-mobile-web-app-capable">
  <meta content="yes" name="apple-touch-fullscreen">
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
  <link rel="stylesheet" type="text/css" href="./css/style.css" />
  <script type="text/javascript" src="./script/jquery.min.js"></script>
  <script type="text/javascript" src="./script/jquery.min.js"></script>
  <script type="text/javascript" src="./script/aui-slide.js"></script>
  <script type="text/javascript" src="./script/jquery.min.js"></script>
  <script type="text/javascript" src="./script/doT.min.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
  <script type="text/javascript" src="./script/api.js"></script></head>
  <script type="text/javascript" src="./script/aui-tab.js" ></script>
  <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<body>

  <header class="head" style="padding-top:0.4rem;">
    <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
    <h3>团队业绩</h3>
    <div class="head-r"></div>
  </header>
  <div class="head-d" style="padding-top:0.4rem;"></div>

  <div id="list2">

    <ul class="my-achievement-team-t">
      <li>
        团队
        <p>5人</p>
      </li>
      <i></i>
      <li>
        直属
        <p>3人</p>
      </li>
    </ul>
    <div class="my-achievement-team-m">
      <i></i>
      <span>直属人员业绩</span>
      <i></i>
    </div>

  </div>
  
  <div id="list">
    <div class="my-achievement-t border-b">
      <dl>
        <dt>张丽娜</dt>
        <dd>用户名：15646874847</dd>
        <dd>日期：2018-09-21  15：20：11</dd>
      </dl>
      <img src="image/gril.png">
    </div>
    <ul class="my-achievement mb20">
     <li>
      当月个人业绩
      <span>100</span>
    </li>
    <li>
      当月团队业绩
      <span>59</span>
    </li>
    <li>
      当月团队组建奖
      <p>￥5000</p>
    </li>
    <li>
      当日个人业绩
      <span>100</span>
    </li>
    <li>
      当日团队业绩
      <span>40</span>
    </li>
    <li>
      当季个人业绩
      <span>20</span>
    </li>
    <li>
      当季团队业绩
      <span>30</span>
    </li> 
  </ul>

</div>

</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>
<script type="text/template" id="template2">

  <ul class="my-achievement-team-t">
    <li>
      团队
      <p>{{=it.number_team}}人</p>
    </li>
    <i></i>
    <li>
      直属
      <p>{{=it.number_personal}}人</p>
    </li>
  </ul>

  <div class="my-achievement-team-m">
    <i></i>
    <span>直属人员业绩</span>
    <i></i>
  </div>

</script>

<script type="text/template" id="template">

  {{~it.data:value:index}}
  <div class="my-achievement-t border-b">
    <dl>
      <dt>{{=value.name}}</dt>
      <dd>用户名：{{=value.phone}}</dd>
      <dd>日期：{{=value.time}}</dd>
    </dl>
    <img src="{{=value.avatar}}">
  </div>
  <ul class="my-achievement mb20">
   <li>
    当月个人业绩
    <span>{{=value.p_month}}</span>
  </li>
  <li>
    当月团队业绩
    <span>{{=value.t_month}}</span>
  </li>
  <li>
    当月个人奖金
    <p>￥{{=value.prize_month}}</p>
  </li>
<!--   <li>
    当日个人业绩
    <span>{{=value.p_day}}</span>
  </li>
  <li>
    当日团队业绩
    <span>{{=value.t_day}}</span>
  </li> -->
  <li>
    当季个人业绩
    <span>{{=value.p_quarter}}</span>
  </li>
  <li>
    当季团队业绩
    <span>{{=value.t_quarter}}</span>
  </li> 
</ul>
{{~}}
</script>
<script type="text/javascript">

  apiready = function(){
    loadData();
    pullLoading();
  }


  function loadData(more){

        // 进度提示框
        api.showProgress({
          title: '努力加载中...',
          text: '请稍等...',
          modal: false
        });

        if (more) {
          page += 1;
        }else{
          page = 1;
        }

        var token = $api.getStorage('token');
        api.ajax({
          url: webAddress + '/api/user/sales/team',
          method: 'get',
          data: {
            values: {
              page: page,
              row: row,
            },
          },
          headers: {
            Authorization: 'Bearer ' + token,
            Accept: 'application/json',
          },
        },function(ret, err){
          if (ret) {
            // alert( JSON.stringify( ret ) );
            // 关闭上拉加载控件
            api.hideProgress();
            // 关闭下拉刷新控件
            // api.refreshHeaderLoadDone();
            if (ret) {
              if (more) {
                templateFun(ret,1);
              }else{
                templateFun(ret);
                templateFun2(ret);
              }
            }
          } else {
              // alert( JSON.stringify( err ) );
            }
          });
      }

    // 模板赋值函数
    function templateFun(data,more){

      var template = $api.byId('template');
      var dotFn = doT.template(template.innerHTML);
      var html = dotFn(data);
      var list = $api.byId('list');
      
      if (more) {

        if (data.data.length) {

          $api.append(list, html);
        }else{

         api.toast({
          msg: '没有更多了',
          duration: 2000,
          location: 'bottom'
        });
         return; 
       }
     }else{
      if (data) {
       $api.html(list, html);
     }else{
      var html = '<h2 style="padding:1rem; text-align:center; color:#999; font-size:0.5rem;">暂无内容</h2>';
      list.innerHTML = html;
    }
  }
}

    // 模板赋值函数
    function templateFun2(data){

      var template = $api.byId('template2');
      var dotFn = doT.template(template.innerHTML);
      var html = dotFn(data);
      var list = $api.byId('list2');
      $api.html(list, html);

    }

    // 上拉加载
    function pullLoading(){
      api.addEventListener({
        name: 'scrolltobottom',
        extra: {
          threshold: 0
        }
      }, function(ret, err){
        loadData(1);
      });
    }

  </script>
  <script type="text/javascript">
    function closeWin(){
      api.closeWin({
      });
    }
  </script>
  </html>